"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TagMiniLayout = TagMiniLayout;

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _components = require("@tarojs/components");

var _icon = _interopRequireDefault(require("../../icon"));

var _configContext = require("../../../extends/configContext");

var _excluded = ["type", "closeable", "size", "onClick", "onClose", "children"];

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function TagMiniLayout(_ref) {
  var _ref$type = _ref.type,
      type = _ref$type === void 0 ? 'default' : _ref$type,
      closeable = _ref.closeable,
      size = _ref.size,
      onClick = _ref.onClick,
      onClose = _ref.onClose,
      children = _ref.children,
      props = _objectWithoutProperties(_ref, _excluded);

  var _useConfig = (0, _configContext.useConfig)(),
      clsPrefix = _useConfig.clsPrefix;

  var handleClose = function handleClose(event) {
    onClose();
    event.stopPropagation();
  };

  return /*#__PURE__*/_react.default.createElement(_components.View, _extends({
    onClick: onClick,
    className: (0, _classnames.default)("".concat(clsPrefix, "-tag"), "".concat(clsPrefix, "-tag--").concat(type), _defineProperty({}, "size-".concat(size), size))
  }, props), /*#__PURE__*/_react.default.createElement(_components.Text, {
    className: "".concat(clsPrefix, "-tag-text")
  }, children), closeable && /*#__PURE__*/_react.default.createElement(_icon.default, {
    className: "".concat(clsPrefix, "-tag-delete"),
    name: "CloseOutlined",
    size: 8,
    onClick: handleClose
  }));
}